package gemini.basic.model;
// default package
// Generated Nov 23, 2010 4:23:01 PM by Hibernate Tools 3.4.0.Beta1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "g_user", catalog = "gemini", uniqueConstraints = {
		@UniqueConstraint(columnNames = "person_id"),
		@UniqueConstraint(columnNames = "username") })
public class User extends AbstractDomain implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer version;
	private Person person;
	private UserStatus userStatus;
	private String username;
	private String password;
	private short retryLoginTimes;
	private short retryPinTimes;
	private Date createdTime;
	private Date validFrom;
	private List<UserStatusLog> userStatusLogs = new ArrayList<UserStatusLog>(0);
	private List<Group> groups = new ArrayList<Group>(0);
	private List<UserNote> userNotes = new ArrayList<UserNote>(0);

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "person_id", unique = true, nullable = false)
	public Person getPerson() {
		return this.person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "status_id", nullable = false)
	public UserStatus getUserStatus() {
		return this.userStatus;
	}

	public void setUserStatus(UserStatus userStatus) {
		this.userStatus = userStatus;
	}

	@Column(name = "username", unique = true, nullable = false, length = 20)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", nullable = false, length = 50)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "retry_login_times", nullable = false)
	public short getRetryLoginTimes() {
		return this.retryLoginTimes;
	}

	public void setRetryLoginTimes(short retryLoginTimes) {
		this.retryLoginTimes = retryLoginTimes;
	}

	@Column(name = "retry_pin_times", nullable = false)
	public short getRetryPinTimes() {
		return this.retryPinTimes;
	}

	public void setRetryPinTimes(short retryPinTimes) {
		this.retryPinTimes = retryPinTimes;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "created_time", nullable = false, length = 10)
	public Date getCreatedTime() {
		return this.createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "valid_from", nullable = false, length = 10)
	public Date getValidFrom() {
		return this.validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public List<UserStatusLog> getUserStatusLogs() {
		return this.userStatusLogs;
	}

	public void setUserStatusLogs(List<UserStatusLog> userStatusLogs) {
		this.userStatusLogs = userStatusLogs;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "g_grant", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "group_id", nullable = false, updatable = false) })
	public List<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public List<UserNote> getUserNotes() {
		return this.userNotes;
	}

	public void setUserNotes(List<UserNote> userNotes) {
		this.userNotes = userNotes;
	}
}
